package io.renren.modules.aic.service.impl;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.ProjectConstant;
import io.renren.common.utils.Query;
import io.renren.modules.aic.dao.CtocOrderDao;
import io.renren.modules.aic.entity.CtocOrderEntity;
import io.renren.modules.aic.service.CtocOrderService;
import io.renren.modules.aic.service.MemberService;

import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

@Service("ctocOrderService")
public class CtocOrderServiceImpl extends ServiceImpl<CtocOrderDao, CtocOrderEntity> implements CtocOrderService {

	@Autowired
	MemberService memberService;

	@Override
	public PageUtils queryPage(Map<String, Object> params) {
		String orderNo = (String) params.get("orderNo");
		String mobile = (String) params.get("mobile");
		String status = (String) params.get("status");

		Page<CtocOrderEntity> page = this.selectPage(
				new Query<CtocOrderEntity>(params).getPage(),
				new EntityWrapper<CtocOrderEntity>().eq("status", status == null ? ProjectConstant.CTOC_ORDER_STATUS_SUBMIT : status)
						.eq(StringUtils.isNotBlank(mobile), "mobile", mobile).eq(StringUtils.isNotBlank(orderNo), "order_no", orderNo));

		return new PageUtils(page);
	}
}
